<template>
	<view class="main-content">
		<MHeader>{{state.pageName}}</MHeader>
		<scroll-view scroll-y="true" style="height:calc(100% - 80rpx)">
			<view>
				<item name="单据编号">
					<view>{{state.info.Data.BillNo}}</view>
				</item>
				<item name="组织">
					<view>{{state.info.Data.F_QUQY_ORGID?.Name[0].Value}}</view>
				</item>
				<item name="甲方">
					<view>{{state.info.Data.F_QUQY_PARTYA?.Name[0].Value}}</view>
				</item>
				<item name="乙方">
					<view>{{state.info.Data.F_QUQY_PARTYB?.Name[0].Value}}</view>
				</item>
				<item name="冷藏厂">
					<view>{{state.info.Data.F_QUQY_LCFACTORY?.Name[0].Value}}</view>
				</item>
				<item name="业务员">
					<view>{{state.info.Data.F_QUQY_YWY?.Name[0].Value}}</view>
				</item>
				<item name="状态">
					<view class="input">{{state.info.Data.DocumentStatus?state.info.status[state.info.Data.DocumentStatus]:''}}</view>
				</item>
				<item name="联系方式">
					<view>{{state.info.Data.F_QUQY_PHONE}}</view>
				</item>
				<item name="养殖地址">
					<view>{{state.info.Data.F_QUQY_ADDRESS}}</view>
				</item>
				<item name="苗采购单价">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_MIAOPRICE}}</view>
					<text class="symbol">元 / 只</text>
				</item>
				<item name="苗采购总价">
					<view style="padding-right: 35rpx;">{{state.info.Data.F_QUQY_MIAOTOTALPRICE}}</view>
					<text class="symbol">元</text>
				</item>
				<item name="合同只数">
					<view style="padding-right: 35rpx;">{{state.info.Data.F_QUQY_HTQTY}}</view>
					<text class="symbol">只</text>
				</item>
				<item name="合同苗单价">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_HTMPRICE}}</view>
					<text class="symbol">元 / 只</text>
				</item>
				<item name="合同苗总价">
					<view style="padding-right: 35rpx;">{{state.info.Data.F_QUQY_HTMTOTALPRICE}}</view>
					<text class="symbol">元</text>
				</item>
				<item name="饲料价格">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_SLPRICE}}</view>
					<text class="symbol">元 / 袋</text>
				</item>
				<item name="标准用料">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_STANDARD}}</view>
					<text class="symbol">斤 / 只</text>
				</item>
				<item name="里程">
					<view style="padding-right: 50rpx;">{{state.info.Data.F_QUQY_MILEAGE}}</view>
					<text class="symbol">KM</text>
				</item>
				<item name="苗供应商">
					<view>{{state.info.Data.F_QUQY_SUPPLIER?.Name[0].Value}}</view>
				</item>
				<item name="是否自购">
					<view>{{state.info.Data.F_QUQY_ISZG}}</view>
				</item>
				<item name="上苗日期">
					<view>{{state.info.Data.F_QUQY_MIAODATE?moment(state.info.Data.F_QUQY_MIAODATE).format('YYYY-MM-DD'):''}}</view>
				</item>
				<item name="回收日期">
					<view>{{state.info.Data.F_QUQY_HSDATE?moment(state.info.Data.F_QUQY_HSDATE).format('YYYY-MM-DD'):''}}</view>
				</item>
				<item name="回收价格">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_HSPRICE}}</view>
					<text class="symbol">元 / 只</text>
				</item>
				<item name="保证金">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_BZJPRICE}}</view>
					<text class="symbol">元 / 只</text>
				</item>
				<item name="风险金">
					<view style="padding-right: 85rpx;">{{state.info.Data.F_QUQY_FXPRICE}}</view>
					<text class="symbol">元 / 只</text>
				</item>
				<item name="源单编号">
					<view>{{state.info.Data.F_QUQY_SourceBillNo}}</view>
				</item>
				<item name="源单类型">
					<view>{{state.sType[state.info.Data.F_QUQY_SourceBillType]}}</view>
				</item>
				<item name="备注">
					<view>{{state.info.Data.F_QUQY_Remark}}</view>
				</item>
			</view>
			<MHeader hidTag>
				<van-icon name="cluster" color="#1989fa" style="margin-right: 10rpx" />
				单据列表
			</MHeader>
			<view style="padding-bottom: 10rpx">
				<view class="card" v-for="(item, index) in state.info.Data.QUQY_BreContractEntry">
					<view class="card-index">{{ index + 1 }}</view>
					<item name="料">
						<view>{{item.F_QUQY_MATERIAL?.Name[0].Value}}</view>
					</item>
					<item name="合同价">
						<view style="padding-right: 115rpx;">{{item.F_QUQY_HTPRICE}}</view>
						<text class="symbol">元 / 千克</text>
					</item>
				</view>
			</view>
		</scroll-view>
	</view>
	<Loading v-if="state.loading"></Loading>
</template>

<script setup>
	import moment from 'moment'
	import { reactive, getCurrentInstance, ref, watch, nextTick } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'
	import { checkForm, msg } from '/utils/utils.js'
	import kdApis from '/api/modularApi/kdApi.js'
	const { proxy } = getCurrentInstance()
	const state = reactive({
		info: {
			FormId: 'QUQY_BreContract',
			Data: {},
			status: {
				Z: '暂 存',
				A: '保 存',
				B: '审核中',
				C: '已审核',
				D: '重新审核'
			}
		},
		sType: {
			QUQY_SeedPlan: '上苗计划'
		},
		pageName: " ",
		loading: true
	})

	const getDetails = (Id) => {
		kdApis.formView({
			formId: 'QUQY_BreContract',
			data: { Id }
		}).then(res => {
			if (res) {
				state.info.Data = res
				state.loading = false
			}
		})
	}

	onLoad(async (query) => {
		if (query.Id) {
			state.pageName = "养殖合同详情"
			getDetails(query.Id)
		}
	})
</script>
<style lang="scss" scoped>
	.card {
		position: relative;
		width: calc(100% - 60rpx);
		margin: 20rpx auto;
		box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
		border-radius: 6rpx;

		.card-index {
			position: absolute;
			display: flex;
			width: 40rpx;
			height: 40rpx;
			padding-left: 10rpx;
			font-size: 24rpx;
			background: #409eff;
			color: #fff;
			clip-path: polygon(0 0, 0 40rpx, 10rpx 40rpx, 40rpx 10rpx, 40rpx 0);
		}
	}
</style>